<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../00_static/js/vue.js" type="text/javascript"></script>
    <title>自定义指令</title>
</head>

<body>
    <!-- 
        1. 功能类型于v-text，转换成大写 v-upper-text
        2. 功能类型于v-text，转换成大写 v-lower-text
     -->

    <div id="app">
        <h2 v-text="msg"></h2>
        <h2 v-upper-text="msg"></h2>
        <h2 v-lower-text="msg"></h2>
    </div>

    <script type="text/javascript">
        // 定义全局自定义指令
        Vue.directive('upper-text', function (el, binding) {
            el.innerText = binding.value.toUpperCase()
        })

        new Vue({
            el: '#app',
            data: {
                msg: 'Test Vue'
            },
            // 局部自定义指令
            directives: {
                'lower-text'(el, binding) {
                    el.innerText = binding.value.toLowerCase()
                }
            }
        })
    </script>
</body>

</html>